﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI;
using System.Collections;
using QuanLiDiemDanh.Object;

namespace QuanLiDiemDanh.Data
{
    public class Get_Data
    {
        AccessData ac = new AccessData();
        public List<Get_Phong_Hoc> Get_Lich_Phong_Khu_nha(string thu, string khu)
        {
            SqlConnection con = ac.GetConnect();
            con.Open();
            SqlCommand cmd = new SqlCommand("Get_Chi_Tiet_Phong_Hoc", con);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add("@thu", System.Data.SqlDbType.NVarChar).Value = thu;
            cmd.Parameters.Add("@khu_nha", System.Data.SqlDbType.NVarChar).Value = khu;

            SqlDataReader read = cmd.ExecuteReader();
            ArrayList rowList = new ArrayList();
            List<Get_Phong_Hoc> lstPhongHoc = new List<Get_Phong_Hoc>();
            while (read.Read())
            {
                Get_Phong_Hoc objPhongHoc = new Get_Phong_Hoc();
                object[] values = new object[read.FieldCount];
                read.GetValues(values);

                objPhongHoc.Ten_khu_nha = (String)values[0];
                objPhongHoc.Ten_phong = (String)values[1];
                objPhongHoc.Thoi_gian = (String)values[2];
                objPhongHoc.Ten_giang_vien = (String)values[3];
                objPhongHoc.Ten_hoc_phan = (String)values[4];
                lstPhongHoc.Add(objPhongHoc);
            }
            cmd.Dispose();
            con.Close();
            return lstPhongHoc;
        }
        public List<Obj_Khu_Nha> Get_So_Tang(String ten_khu)
        {
            SqlConnection con = ac.GetConnect();
            con.Open();
            SqlCommand cmd = new SqlCommand("Get_Tang_Phong_Khu_Nha", con);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add("@ten_khu_nha", System.Data.SqlDbType.NVarChar).Value = ten_khu;
           

            SqlDataReader read = cmd.ExecuteReader();
            List<Obj_Khu_Nha> lstPhongHoc = new List<Obj_Khu_Nha>();
            while (read.Read())
            {
                Obj_Khu_Nha objPhongHoc = new Obj_Khu_Nha();
                object[] values = new object[read.FieldCount];
                read.GetValues(values);

                objPhongHoc.Ma_khu_nha =values[0].ToString();
                objPhongHoc.Ten_khu_nha = (String)values[1];
                objPhongHoc.So_tang = values[2].ToString();
                objPhongHoc.So_phong =values[3].ToString();
              
                lstPhongHoc.Add(objPhongHoc);
            }
            cmd.Dispose();
            con.Close();
            return lstPhongHoc;
        }

    }
}